<template>
  <input type="text" placeholder="请输入数字1" v-model="n1">
  <input type="text" placeholder="请输入数字2" v-model="n2">
  <button @click="cal('+')">加</button>
  <button @click="cal('-')">减</button>
  <button @click="cal('*')">乘</button>
  <button @click="cal('/')">除</button>
  <h4>运算结果:{{result}}</h4>
</template>

<script setup>
import {ref} from "vue";
const n1 = ref('');
const n2 = ref('');
const result = ref('0');
const cal = (x)=>{
  // eval(字符串)  可以将字符串以js代码的形式运行
  result.value = eval(n1.value+x+n2.value);
}
</script>

<style scoped>

</style>